<?php
/**
 * Author:   tangxiaowen
 * Email:    846506584@qq.com
 * Date:     2019/5/22 0022
 * Describe: 系统类
 */

namespace app\common\model;

use think\Model;

class System extends Model
{
    /**
     * 获取系统信息
     * @return array
     */
    public function getSystemInfo()
    {
        return db('sys_basicinfo')->find();
    }

    /**
     * 获取对接第三方配置参数
     * @param string $eName 第三方配置英文名称
     * @param bool $isCache 是否从缓存获取|默认否
     * @param integer $cacheTime 数据缓存时间|默认60秒
     * @return array
     */
    public function getServerConfig($eName, $isCache = false, $cacheTime = '60')
    {
        if($isCache){
            $data = cache($eName);
            if(!$data){
                $data = $data = db('sys_integrate')->alias('i')
                    ->join('xb_sys_inteparameter in', 'i.ID = in.IntegrateID')
                    ->where(['i.Status' => 1, 'i.EName' => $eName])
                    ->select();
                cache($eName,$data,$cacheTime);
                $data = cache($eName);
            }
            return $data;
        }else{
            return $data = db('sys_integrate')->alias('i')
                ->join('xb_sys_inteparameter in', 'i.ID = in.IntegrateID')
                ->where(['i.Status' => 1, 'i.EName' => $eName])
                ->select();
        }
    }

}